package sjtu.ist.warehouse4ws.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.json.annotations.JSON;


import sjtu.ist.warehouse4ws.model.Department;
import sjtu.ist.warehouse4ws.model.Permissionresources;
import sjtu.ist.warehouse4ws.service.PermissionresourcesService;



import com.opensymphony.xwork2.ActionSupport;

public class ShowPermissionresourcesAction extends ActionSupport{
	private List <Permissionresources> prList=new ArrayList<Permissionresources> ();
	private PermissionresourcesService prService;
	
	private String id;
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setPermissionresourcesService(PermissionresourcesService prService) {
		this.prService = prService;
	}
	
	public String showPermissionresources(){
		HttpServletRequest request = ServletActionContext.getRequest ();
		this.id=request.getParameter("cid");
		this.prList=prService.getPermissionresourcesById(id);
		System.out.print(prList.size());
		return SUCCESS;
	}
	
	@JSON(name="totalPermissionresources")	
	public int getTotalPermissionresources() {
		return this.prList.size();
	}
    
	@JSON(name="Permissionresources")	
	public List<Permissionresources> getPermissionresourcesList() {
		return this.prList;
	}

}
